package cn.study.zgm.nettyall.channel;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * packageName cn.study.zgm.nettyall.channel
 *
 * @author 你的名字
 * @version JDK 8
 * @className ByteBufferScatterRead (此处以class为例)
 * @date 2025/2/24
 * @description TODO
 */
public class StringScatterChannelRead {
    public static void main(String[] args) {
        try(final FileChannel fileChannel = new RandomAccessFile("scatterRead.txt", "r").getChannel()){
            ByteBuffer buffer1 = ByteBuffer.allocate(2);
            ByteBuffer buffer2 = ByteBuffer.allocate(3);
            ByteBuffer buffer3 = ByteBuffer.allocate(5);
            final long read = fileChannel.read(new ByteBuffer[]{buffer1, buffer2, buffer3});
            buffer1.flip();
            buffer2.flip();
            buffer3.flip();
            ByteBufferUtil.debugAll(buffer1);
            ByteBufferUtil.debugAll(buffer2);
            ByteBufferUtil.debugAll(buffer3);
        }catch (IOException e){

        }


    }
}
